﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using STLGROUP.Layers.Base;
using STLGROUP.Layers.DataAccessLayers;

namespace STLGROUP.Layers.BLL
{
    public class DatHangBLL:BaseBLL
    {
        /// <summary>
        /// Get data
        /// </summary>
        /// <param name="pIDNhaCungCap"></param>
        /// <param name="pIDLoaiSanPham"></param>
        /// <param name="pIsSoLuongCanhBao"></param>
        /// <returns></returns>
        /// <author>viet sang</author>
        /// <date>24/04/2012</date>
        public IQueryable<View_SanPham> GetSanPhamByContidions(int? pIDNhaCungCap, int? pIDLoaiSanPham, bool pIsSoLuongCanhBao=false)
        {
            //get data
            var data = this.Context.View_SanPham
                .Where(s => (!pIDNhaCungCap.HasValue || s.IDNhaCungCap == pIDNhaCungCap)
                    && (!pIDLoaiSanPham.HasValue || s.IDLoaiSanPham == pIDLoaiSanPham));

            if (pIsSoLuongCanhBao == true)
            {
                data = data.Where(s => s.SoLuongCanhBao.HasValue && s.SoLuongCanhBao > s.SoLuongTonKho);
            }

            return data;
        }

    }
}
